package com.lagou.plugin;

import org.apache.ibatis.executor.statement.StatementHandler;
import org.apache.ibatis.plugin.*;

import java.sql.Connection;
import java.util.Properties;

/**
 * @author lyloou
 * @date 2020/05/24
 * @desc
 */

@Intercepts({
        @Signature(type = StatementHandler.class, method = "prepare", args = {
                Connection.class, Integer.class
        })
})
public class MyPlugin implements Interceptor {
    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        System.out.println("通过MyPlugin进行了增强");
        return invocation.proceed();
    }

    @Override
    public Object plugin(Object o) {
        System.out.println("插入");
        return Plugin.wrap(o, this);
    }

    @Override
    public void setProperties(Properties properties) {
        System.out.println("读取 MyPlugin 配置的属性：" + properties);
    }
}
